/**
*******************************************************
*@file  message_handle.c
*@brief message_handle.c
*@author 花满楼
*@date     2020-6-24
*@version  V1
*@attention none
*******************************************************
*/
#include "can.h"
#include "rs485.h"


/**
*******************************************************
*@brief 处理CAN通讯数据
*@param   CAN_RxMessage:数据接收结构体
*@return  none
*@note    none
*******************************************************
*/
u32 Message_Handle(CanRxMsgTypeDef *CAN_RxMessage)
{
    u32 CAN_ID;
    CAN_ID = CAN_RxMessage->ExtId;

    if ((CAN_RxMessage->IDE == 4) && (CAN_RxMessage->RTR == 0))
    {
        if ((CAN_ID & 0xFFFF) == 0xF040)
        {
            if (CAN_ID == PC2M_0)
            {
                CAN1_Receive_DebugMsg(CAN_RxMessage);
                return 0;
            }
        }
    }

    return 0;
}

/**
*******************************************************
*@brief 处理CAN通讯数据
*@param   CAN_RxMessage:数据接收结构体
*@return  none
*@note    none
*******************************************************
*/
void CAN1_Receive_DebugMsg(CanRxMsgTypeDef *CAN_RxMessage)
{
    Control_Reg.Control1.Word = ((CAN_RxMessage->Data[1] << 8) | CAN_RxMessage->Data[0]);
    Control_Reg.Control2.Word = ((CAN_RxMessage->Data[3] << 8) | CAN_RxMessage->Data[2]);
    Control_Reg.Control3.Word = ((CAN_RxMessage->Data[5] << 8) | CAN_RxMessage->Data[4]);
    Control_Reg.Control4.Word = ((CAN_RxMessage->Data[7] << 8) | CAN_RxMessage->Data[6]);
}
